﻿// Serotonin -- easy-to-use image filters application
// https://code.google.com/p/serotonin/
//
// Copyright © Frank Nagl, 2012-2013
// admin@franknagl.de
//
using Serotonin.Filter;
using System.Windows.Forms;
namespace Serotonin.OptionsForms
{
    /// <summary> Defines properties for an options form. </summary>
    public interface IOptionsForm
    {
        /// <summary>
        /// The processor for managing the images and the image GUI panel.
        /// </summary>
        Processor Processor { get; set; }

        ///<summary>Applies the specified filter in the options form.</summary>
        void ApplyFilter();

        /// <summary>
        /// Sets the language specified string texts for the form elements.
        /// </summary>
        void SetStrings();
    }

    /// <summary>
    /// Provides static methods for simulating an abstract OptionsForm class (
    /// as root parent for all IOptionsForms). This cannot be done, because 
    /// the Form-Designer does not allow a parent class for a form.
    /// AOF means 'AbstractOptionsForm'.
    /// </summary>
    public static class AOF
    {
        /// <summary>
        /// Initializes the specified IOptionsForm.
        /// </summary>
        /// <param name="processor">The processor.</param>
        /// <param name="iform">The IOptionsForm to initialize.</param>
        /// <param name="gbProcess">The process gropuBox of the IOptionsForm.</param>
        /// <param name="filter">The filter of the IOptionsForm.</param>
        /// <returns>
        /// The <paramref name="filter" /> of the IOptionsForm.
        /// </returns>
        public static AbstractFilter Init(  Processor processor,
                                            IOptionsForm iform, 
                                            GroupBox gbProcess,                                         
                                            AbstractFilter filter
                                            )
        {
            iform.Processor = processor;
            iform.SetStrings();
            iform.Processor.GbProcess = gbProcess;
            iform.Processor.RemoveAllApplyEvents();
            iform.Processor.ApplyEvent += iform.ApplyFilter;
            return filter;
        }
    }
}
